<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base2.css,base_new.css'); }
    {php echo Common::getScript("jquery.validate.js"); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,choose.js,product_add.js,imageup.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }
    {php echo Common::getScript('config.js');}
    <style>
        .error{
            color:red;
            padding-left:5px;
        }
        .hide{
            display: none;
        }

    </style>

</head>
<body>

<table class="content-tab">
    <tr>
        <td width="119px" class="content-lt-td" valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--右侧内容区-->
        </td>
        <td valign="top" class="content-rt-td">
            <form id="configfrm">
                <div class="w-set-con">
                    <div class="cfg-header-bar">
                        <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
                    </div>
                    <div class="clear">

                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd">网站LOGO{Common::get_help_icon('cfg_supplier_logo')}：</span>
                                <div class="item-bd">

                                    <a href="javascript:;" id="file_upload" class="btn btn-primary radius size-S mt-5">上传图片</a>
                                    <a href="javascript:;" class="btn btn-grey-outline radius size-S mt-5 ml-5" onClick="delad()">恢复默认</a>

                                    <div class="clear logolist pt-10">
                                        <img src="" id="adimg" class="up-img-area" />
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">LOGO链接：</span>
                                <div class="item-bd">
                                    <input type="text" name="cfg_supplier_logourl" id="cfg_supplier_logourl" class="input-text w900" >
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">LOGO说明：</span>
                                <div class="item-bd">
                                    <input type="text" name="cfg_supplier_logotitle" id="cfg_supplier_logotitle" class="input-text w900" />
                                </div>
                            </li>
                        </ul>

                        <div class="clear">
                            <a class="btn btn-primary radius size-L ml-115" href="javascript:;" id="btn_save">保存</a>
                            <input type="hidden" name="webid" id="webid" value="0">
                            <input type="hidden" name="cfg_supplier_logo" id="cfg_supplier_logo" value=""/>
                            <input type="hidden" name="cfg_supplier_logodisplay" id="cfg_supplier_logodisplay" value=""/>
                        </div>

                    </div>
                </div>
            </form>

        </td>
    </tr>
</table>

<script>
    $(document).ready(function(){

        //选中导航
        $('.leftnav').find('a').each(function(i,obj){
            var dataUrl = $(obj).data('url');
            if(dataUrl == '/plugins/supplier/set/logo/parentkey/supplier/itemid/1'){
                $(obj).addClass('active');
            }
        })


        //配置信息保存
        $("#btn_save").click(function(){
            var display = '';
            //显示的栏目
            $("input[name='display']").each(function(){
                if($(this).is(':checked'))
                {
                    display=display+$(this).attr('value')+',';
                }
            })
            $("#cfg_supplier_logodisplay").val(display);
            var webid= $("#webid").val();
            Config.saveConfig(webid);
        })

        //文件上传
        var webid=$("#webid").val();

        //上传图片
        $('#file_upload').click(function(){
            ST.Util.showBox('上传logo', SITEURL + 'image/insert_view', 0,0, null, null, parent.document, {loadWindow: window, loadCallback: Insert});
            function Insert(result,bool){

                var temp =result.data[0].split('$$');
                var src = temp[0];
                if(src){
                    $("#adimg").attr('src',src);
                    $('#cfg_supplier_logo').val(src);

                }

            }
        })
        getConfig(0);
    });


    //获取配置
    function getConfig(webid)
    {
        Config.getConfig(webid,function(data){
            $("#cfg_supplier_logourl").val(data.cfg_supplier_logourl);
            $("#cfg_supplier_logotitle").val(data.cfg_supplier_logotitle);
            $("#cfg_supplier_logo").val(data.cfg_supplier_logo);
            $("#cfg_supplier_logodisplay").val(data.cfg_supplier_logodisplay);
            if(data.cfg_supplier_logo!='')
            {
                $("#adimg").attr('src',data.cfg_supplier_logo);
            }
            else
            {
                $("#adimg").attr('src',SITEURL+'public/images/pic_tem.gif');
            }
        })


    }
    //删除图片
    function delad()
    {
        var adfile=$("#cfg_supplier_logo").val();
        var webid = $("#webid").val();
        if(adfile=='')
        {
            ST.Util.showMsg('还没有上传图片',1,1000);
        }
        else
        {
            $.ajax({
                type: "post",
                data: {picturepath:adfile,webid:webid},
                url: SITEURL+"uploader/delpicture",
                success: function(data,textStatus)
                {
                    if(data=='ok')
                    {
                        $("#adimg")[0].src=SITEURL+'public/images/pic_tem.gif';
                        $("#cfg_supplier_logo").val('');

                    }
                }

            });
        }

    }
    //获取logo显示位置
    function getLogoDisplay(webid,displayids)
    {
        $.ajax({
            type: "post",
            data: {logodisplay:displayids,webid:webid},
            url: SITEURL+"config/ajax_getlogodisplay",
            success: function(data,textStatus)
            {
                $("#display_set").html(data)

            }

        });
    }

</script>

</body>
</html>
